package com.css.fxfzysx.modules.vabStructure.constans;

import com.css.fxfzysx.constants.FxfzConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

//四类
@Getter
@AllArgsConstructor
public enum BuildingRoofEnum {

    BUILDING_ROOF1(1, "现浇或装配整体式钢筋混凝土楼、屋盖"),
    BUILDING_ROOF2(2, "装配式钢筋混凝土楼、屋盖"),
    BUILDING_ROOF3(3, "木屋盖"),
    BUILDING_ROOF4(4, "其他");


    private final Integer code;
    private final String name;

    public static Integer getByName1(String name) {
        for (BuildingRoofEnum value : BuildingRoofEnum.values()) {
            if (value.getName().equals(name)) {
                return value.code;
            }
        }
        return null;
    }

    @Getter
    @AllArgsConstructor
    enum IntensityEnum {
        INTENSITY6(6, "6度"),
        INTENSITY7(7, "7度"),
        INTENSITY8(8, "8度"),
        INTENSITY9(9, "9度"),
        INTENSITY10(6, "未设防"),
        INTENSITY11(6, "自设防"),
        INTENSITY12(6, "其他");

        private Integer code;
        private String name;
    }

    public static Integer getByName(String name) {
        for (IntensityEnum value : IntensityEnum.values()) {
            if (value.getName().equals(name)) {
                return value.code;
            }
        }
        return null;
    }


        @Getter
        @AllArgsConstructor
        enum IntensityValueEnum {
            INTENSITY6(6, FxfzConstants.BuildingRoofCodeList, FxfzConstants.valueList6),
            INTENSITY7(7, FxfzConstants.BuildingRoofCodeList, FxfzConstants.valueList6),
            INTENSITY8(8, FxfzConstants.BuildingRoofCodeList, FxfzConstants.valueList8),
            INTENSITY9(9, FxfzConstants.BuildingRoofCodeList, FxfzConstants.valueList9);

            private final Integer intensity;
            private final Integer[] BuildingRoofCodeList;
            private final Double[] valueList;
        }

        public static Double getByCode (Integer code, Double spacing, Integer intensity){
            for (BuildingRoofEnum value : BuildingRoofEnum.values()) {
                if (value.getCode().equals(code)) {
                    for (IntensityValueEnum intensityValueEnum : IntensityValueEnum.values()) {
                        if (intensity.equals(intensityValueEnum.getIntensity())) {
                            Double[] valueList = intensityValueEnum.getValueList();
                            if (spacing < valueList[code - 1]) {
                                //满足
                                return 0.0;
                            }
                        }
                    }
                }
            }
            return 0.1;
        }
    }
